Commit | Line | Data |
---|---|---|
e87b4ac1 PR |
1 | // This may look like C code, but it is really -*- C++ -*- |
2 | /* | |
3 | Copyright (C) 1988 Free Software Foundation | |
4 | written by Doug Lea (dl@rocky.oswego.edu) | |
5 | ||
6 | This file is part of the GNU C++ Library. This library is free | |
7 | software; you can redistribute it and/or modify it under the terms of | |
8 | the GNU Library General Public License as published by the Free | |
9 | Software Foundation; either version 2 of the License, or (at your | |
10 | option) any later version. This library is distributed in the hope | |
11 | that it will be useful, but WITHOUT ANY WARRANTY; without even the | |
12 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR | |
13 | PURPOSE. See the GNU Library General Public License for more details. | |
14 | You should have received a copy of the GNU Library General Public | |
15 | License along with this library; if not, write to the Free Software | |
16 | Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
17 | */ | |
18 | ||
19 | ||
20 | #ifndef _<T>VHBag_h | |
21 | #ifdef __GNUG__ | |
22 | #pragma interface | |
23 | #endif | |
24 | #define _<T>VHBag_h 1 | |
25 | ||
26 | #include "<T>.Bag.h" | |
27 | ||
28 | ||
29 | class <T>VHBag : public <T>Bag | |
30 | { | |
31 | protected: | |
32 | <T>* tab; | |
33 | char* status; | |
34 | unsigned int size; | |
35 | ||
36 | public: | |
37 | <T>VHBag(unsigned int sz = DEFAULT_INITIAL_CAPACITY); | |
38 | <T>VHBag(<T>VHBag& a); | |
39 | ~<T>VHBag(); | |
40 | ||
41 | Pix add(<T&> item); | |
42 | void del(<T&> item); | |
43 | void remove(<T&>item); | |
44 | int nof(<T&> item); | |
45 | int contains(<T&> item); | |
46 | ||
47 | void clear(); | |
48 | ||
49 | Pix first(); | |
50 | void next(Pix& i); | |
51 | <T>& operator () (Pix i); | |
52 | Pix seek(<T&> item, Pix from = 0); | |
53 | ||
54 | int capacity(); | |
55 | void resize(unsigned int newsize = 0); | |
56 | ||
57 | int OK(); | |
58 | }; | |
59 | ||
60 | ||
61 | inline <T>VHBag::~<T>VHBag() | |
62 | { | |
63 | delete [] tab; | |
64 | delete status; | |
65 | } | |
66 | ||
67 | ||
68 | inline int <T>VHBag::capacity() | |
69 | { | |
70 | return size; | |
71 | } | |
72 | ||
73 | inline int <T>VHBag::contains(<T&> key) | |
74 | { | |
75 | return seek(key) != 0; | |
76 | } | |
77 | ||
78 | inline <T>& <T>VHBag::operator () (Pix i) | |
79 | { | |
80 | if (i == 0) error("null Pix"); | |
81 | return *((<T>*)i); | |
82 | } | |
83 | ||
84 | #endif |